import redis
import json

client = redis.Redis(host='39.105.153.251',password='@huqiao123')

print('开始接收消息：···')
# 生成一个发布/订阅对象，并忽略订阅成功的消息
listener = client.pubsub(ignore_subscribe_messages=True)
# listener.subscribe('dzyj.dzqr')
listener.subscribe('test')

for message in listener.listen():
    channel = message['channel'].decode()
    print(channel)
    data = json.loads(message['data'].decode())
    print(data)
    # break
